
mPhoneMap = {
	##### 长元音 #####
	"ɑ:": "AA1",					#啊	2.3.4		bar,mark,father
	"ɔ:": "AO1",					#噢	11.12.13[1]	law,call,broad
	"ɜ:": "ER1",					#呃 27.28.29	bird,word,learn
	"i:": "IY1",	"i": "IY0",		#噫	39.40.41	sheep,cheap,tea
	"u:": "UW1",	"u": "UW0",		#呜 63.64.65	duty,excuse,student
	##### 短元音 #####
	"ʌ": "AH1",						#啊 8.9.10[0]	run,son,bus
	"ɒ": "AO0",						#噢	11.12.13[0]	hot,not,off
	"ə": "AH0",						#呃	8.9.10[0]	panda,actor,sofa
	"ɪ": "IH1",						#噫	36.37.38	sit,fish,king
	"ʊ": "UH1",						#乌	60.61.62	book,good,pull
	"ɛ": "EH0",		"e": "EH1",		#哎(小)24.25.26	bed,check,set
	"æ": "AE1",						#哎(大)5.6.7	cat,rabbit,happy
	##### 双元音 #####
	"aɪ": "AY1",					#爱	17.18.19	write,why,fight
	"eɪ": "EY1",					#诶	30.31.32	wait,late,hate
	"ɔɪ": "OY1",					#哦咿 51.52.53	noise,point,oil
	"ɪə": "IY1 R",					#咿呃			beer,deer,tear
	"eə": "EH1 R",					#诶呃			air,bear,care
	"əʊ": "OW1",	"oʊ": "OW1",	#呃呜 48.49.50	goat,bowl,pose
	"aʊ": "AW1",					#嗷呜 14.15.16	mouse,cloud,south
	"ʊə": "UH1 R",					#雾呃 ʊə		tour,cruel,cure

	#####################################
	#### 清辅音 ####
	"p": "P",		#54
	"t": "T",		#58
	"k": "K",		#43
	"f": "F",		#33
	"θ": "TH",		#59
	"s": "S",		#56

	"ʃ": "SH",		#57
	"h": "HH",		#35
	"tʃ": "CH",		#21
	#ts
	#tr
	#### 浊辅音 ####
	"b": "B",		#20
	"d": "D",		#22
	"ɡ": "G",	"g": "G",	#34
	"v": "V",		#66
	"ð": "DH",		#23
	"z": "Z",		#69

	"ʒ": "ZH",		#70
	"r": "R",		#55
	"dʒ": "JH",		#42
	#dz
	#dr
	#### 鼻音 ####
	"m": "M",		#45
	"n": "N",		#46
	"ŋ": "NG",		#47
	#### 半元音 ####
	"j": "Y",		#68
	"w": "W",		#67
	#### 舌边音 ####
	"l": "L",		#44
}


with open('clean.txt', 'r') as tFileIn:
	tFileInLines = tFileIn.readlines()

	for tFileInLine in tFileInLines:
		tSplit = tFileInLine.split("\t")

		## 单词
		tWord = tSplit[0]

		## 音标
		tSymbols = tSplit[1]
		tSymbols = tSymbols.replace("[", "")
		tSymbols = tSymbols.replace("]", "")
		tSymbols = tSymbols.replace("\n", "")
		tSymbols = tSymbols.replace("ː", ":")

		print(">>>>>>>>", tWord, tSymbols)
		##############################

		## 合并
		tSkipFlag = False
		tCombine = []
		tSymbolLen = len(tSymbols)
		for i in range(tSymbolLen):
			tCurrSymbol = tSymbols[i]

			if(tSkipFlag):
				tSkipFlag = False
				continue
			
			if(i+1<tSymbolLen):
				tNextSymbol = tSymbols[i+1]
				if(tNextSymbol==":" or tNextSymbol=="ː"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol+":")
					continue
					
				elif (tCurrSymbol=="d" and tNextSymbol=="ʒ") or (tCurrSymbol=="t" and tNextSymbol=="ʃ"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue

				elif(tCurrSymbol=="a" and (tNextSymbol=="ɪ" or tNextSymbol=="ʊ")):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif(tCurrSymbol=="e" and (tNextSymbol=="ɪ" or tNextSymbol=="ə")):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif (tCurrSymbol=="ɔ" and tNextSymbol=="ɪ"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif(tCurrSymbol=="ɪ" and tNextSymbol=="ə"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif(tCurrSymbol=="o" and tNextSymbol=="ʊ"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif(tCurrSymbol=="ə" and tNextSymbol=="ʊ"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue
				elif(tCurrSymbol=="ʊ" and tNextSymbol=="ə"):
					tSkipFlag = True
					tCombine.append(tCurrSymbol + tNextSymbol)
					continue

			tCombine.append(tCurrSymbol)

		print(tCombine)
		##############################

		tPhonemeVec = []
		for tCom in tCombine:
			if(tCom == "ˈ" or tCom == "ˌ" or tCom == " "):
				continue

			tPhonemeVec.append(mPhoneMap[tCom])

		print(">>>>>>>>", tPhonemeVec)

